package org.noote.libs.spidy.comm;

public class IPServerCommandProtocol {

	//////////////////////////////////
	///
	/// Server class for IP communication
	///
	/////////////////////////////////
	static final String CMD_START_TRAME = "#";
	static final String CMD_END_TRAME = "$";
	protected static String _bounding(String sCmd, String sOp, String sParams)
	{
		return CMD_START_TRAME+sCmd+((sOp.length()>0)?"_"+sOp:"")+":"+sParams+CMD_END_TRAME+"\n";
	}

	/////////////////////////////////
	// Version
	static final String CMD_QUIT = "quit";
	public static String sendQuit()
	{
		return _bounding(CMD_QUIT, "", "");
	}

	/////////////////////////////////
	// Version
	static final String CMD_VERSION = "version";
	public static String sendHello(String sVersion, String sControllerName)
	{
		return _bounding(CMD_VERSION, "hello", "version="+sVersion+",name="+sControllerName);
	}
	public static String sendVersion(String sVersion, String sControllerName)
	{
		return _bounding(CMD_VERSION, "", "version="+sVersion+",name="+sControllerName);
	}

	/////////////////////////////////
	// settings...
	static final String CMD_SETTING = "setting";
	public static String sendSettings(boolean bReport_Transmission)
	{
		return _bounding(CMD_SETTING, "", "send_status="+(bReport_Transmission?"1":"0"));
	}
	public static String sendSettingsCameraBroadcast(String sHostname, int iPort)
	{
		return _bounding(CMD_SETTING, "camera_bc", "hostname="+sHostname+",port="+Integer.toString(iPort));
	}
}
